const mongoose = require('mongoose')

// 连接数据库
async function connect() {
  try {
    await mongoose.connect('mongodb://localhost/mydb', {
      useNewUrlParser: true,
      useUnifiedTopology: true,
    })
    console.log('数据库连接成功')
  } catch (err) {
    console.log(err, '数据库连接失败')
  }
}

connect()